package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IProductCateService;
import com.mall.shopping.IProductService;
import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.AllProductCateRequest;
import com.mall.shopping.dto.AllProductCateResponse;
import com.mall.user.annotation.Anoymous;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.Response;
import java.util.Timer;

/**
 * @Author panda
 * @Date 2021/5/23 17:15
 * @Description:
 * @Version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/shopping")
public class CategoriesController {
    @Reference(timeout = 3000,check = false)
    IProductCateService iProductCateService;

    @RequestMapping("/categories")
    @Anoymous
    public ResponseData categories(HttpServletRequest request){

        AllProductCateRequest allProductCateRequest = new AllProductCateRequest();
        allProductCateRequest.setSort("1");//sort代表是否排序
//        AllProductCateResponse response = iProductCateService.getAllProductCate(allProductCateRequest);
        AllProductCateResponse response = iProductCateService.getAllProductCate();

        if(response.getCode().equals(ShoppingRetCode.SUCCESS.getCode())){
            return new ResponseUtil<>().setData(response.getProductCateDtoList());
        }
        return new ResponseUtil<>().setErrorMsg(response.getMsg());
    }
}
